package stringProcessing;

import java.io.PrintStream;

public final class EscapeUtils {
	public static String escape(String str) {
		int cnt = str.length();
		StringBuilder result = new StringBuilder();
		if ((cnt == 0) && ((str.contains("%")) || (str.contains("％")) || (str.contains("_")) || (str.contains("＿")))) {
			result.append(new StringBuilder().append("$").append(str).toString());
		} else {
			char[] chars = str.toCharArray();
			for (int i = 0; i < chars.length; i++) {
				String chr = Character.valueOf(chars[i]).toString();
				if ((chr.equals("%")) || (chr.equals("％")) || (chr.equals("_")) || (chr.equals("＿"))) {
					result.append(new StringBuilder().append("$").append(chr).toString());
				} else {
					result.append(chr);
				}
			}
		}

		return result.toString();
	}

	public static void main(String[] args) {
		System.out.println(escape("hoge"));
		System.out.println(escape("ho%ge"));
		System.out.println(escape("ho％ge"));
		System.out.println(escape("ho_ge"));
		System.out.println(escape("ho＿ge"));
	}
}